package com.usefullc.common.enums;


import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.StringUtils;


/**
 * 用户绑定类型
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum OuterUserBindTypeEnum {


    WECHAT(0, "wechat","微信"),

    WEIBO(1, "weibo","微博"),

    API(2, "api","第三方API"),



    ;


    private int code;
    private String enName;
    private String value;

    OuterUserBindTypeEnum(int code, String enNane, String value) {
        this.code = code;
        this.enName = enNane;
        this.value = value;
    }

    public static OuterUserBindTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (OuterUserBindTypeEnum s : OuterUserBindTypeEnum.values()) {
            if (s.getCode() == code) {
                return s;
            }
        }
        return null;
    }


    public static OuterUserBindTypeEnum getByEnName(String enName) {
        if (StringUtils.isEmpty(enName)) {
            return null;
        }
        for (OuterUserBindTypeEnum s : OuterUserBindTypeEnum.values()) {
            if (s.getEnName().equals(enName)) {
                return s;
            }
        }
        return null;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getValue() {
        //国际化，重写desc TODO

        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getEnName() {
        return enName;
    }

    public void setEnName(String enName) {
        this.enName = enName;
    }
}
